#!/bin/bash
########################################################################   
#    Dooplet is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Dooplet is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Dooplet.  If not, see <http://www.gnu.org/licenses/>.
#######################################################################
#    Authors: Karthikeyan Manivannan
#
######################################################################

#First point to prepare a package
#set -e

temp_crontab_file="/usr/dooplet/crontab.temp"
id_file="/usr/dooplet/laptop_id.txt"

# remove dooplet rule from crontab
current_crontab=`crontab -l 2>/dev/null`
echo "$current_crontab" > "$temp_crontab_file"
sed -i '/dooplet/ d' "$temp_crontab_file"
crontab "$temp_crontab_file" 2>/dev/null

# remove files that are not part of the package
rm "$temp_crontab_file"
rm "$id_file"
CHECKBOX_SHARE="/usr/share/checkbox"
if [ -f "$CHECKBOX_SHARE/configs/checkbox.ini.old" ];
then
   mv "$CHECKBOX_SHARE/configs/checkbox.ini.old" "$CHECKBOX_SHARE/configs/checkbox.ini"
fi
if [ -d "$CHECKBOX_SHARE/olds" ];
then
   mv "$CHECKBOX_SHARE/olds/*" "$CHECKBOX_SHARE/jobs/"
fi





#rm "$CHECKBOX_SHARE/olds"
